package ca.ubc.icapture.genapha.actions;

import ca.ubc.icapture.genapha.forms.AnalysisResultsForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.Action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import icapture.SQLMgr;

/**
 * Created by IntelliJ IDEA.
 * User: btripp
 * Date: Sep 13, 2006
 * Time: 9:39:08 AM
 * To change this template use File | Settings | File Templates.
 */
public class AnalysisResultsAction extends Action {

   /**
	* Constructor
	*/
	public AnalysisResultsAction() {
		super();
	}

    @Override
    public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {

        ActionForward forward = new ActionForward();
        //HttpSession session = request.getSession();
        AnalysisResultsForm resultsForm = (AnalysisResultsForm) form;
        try{
            if(resultsForm.getJobID()!=null){
                resultsForm.setJob(SQLMgr.getAnalysisJob(Integer.parseInt(resultsForm.getJobID())));
            }
        }catch(Exception e){}
        forward = mapping.findForward("display");

        return forward;
    }
}
